package io.gitee.zhucan123.core.infrastructure.util;

import junit.framework.AssertionFailedError;

import java.util.Collection;

/**
 * JUnit Asserts s pro plus max
 *
 * @author guodu
 * @date 2019/12/26
 */
public class AssertsPro {

  static void fail(Collection expected, Collection actual) {
    System.err.println("Expected: " + StringUtils.join(", ", expected, ele -> ele.toString()));
    System.err.println("Actual  : " + StringUtils.join(", ", actual, ele -> ele.toString()));
    throw new AssertionFailedError();
  }

  public static void assertCollectionEquals(Collection col1, Collection col2) {
    if (col1.size() != col2.size()) {
      fail(col1, col2);
    }
    for (Object e : col1) {
      if (!col2.contains(e)) {
        fail(col1, col2);
        return;
      }
    }
  }

}
